import { useState } from 'react'
import logo from './logo.svg'
import './App.css'
import { Switch, Route, Link } from 'react-router-dom';
import Home from '@/pages/Home';
import About from '@/pages/About';
import Contact from '@/pages/Contact';

function App() {
  const [count, setCount] = useState(0)

  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>Hello Vite + React!</p>
        <p>
          <button type="button" onClick={() => setCount((count) => count + 1)}>
            count is: {count}
          </button>
        </p>
        <p>
          Edit <code>App.tsx</code> and save to test HMR updates.
        </p>
        <p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
          {' | '}
          <a
            className="App-link"
            href="https://vitejs.dev/guide/features.html"
            target="_blank"
            rel="noopener noreferrer"
          >
            Vite Docs
          </a>
        </p>
      </header>

      {/* 导航链接 */}
      <nav>
        <Link to="/">首页</Link> |
        <Link to="/about">关于我们</Link> |
        <Link to="/contact">联系我们</Link>
      </nav>

      {/* 路由出口 - 匹配的组件将在这里渲染 */}
      <Switch>
        {/* exact 精确匹配路径 */}
        <Route exact path="/" component={Home} />
        <Route exact path="/about" component={About} />
        <Route exact path="/contact" component={Contact} />
        {/* 404页面 */}
        <Route component={() => <div>页面未找到</div>} />
      </Switch>
    </div>
  )
}

export default App
